JBoss Community Archive (Read Only)

XNIO

Message Channels

A message channel is a type of channel which supports individual framing of messages. Like stream channels, message channels come in half- and full-duplex variants, with additional subvariants for readable and writable half-duplex channels, known as MessageChannels, ReadableMessageChannels, and WritableMessageChannels.

Writing a message to a message channel will cause the exact message to be delivered to the remote reader; the size and division of messages is preserved. This implies that when you receive a message, your buffer must be large enough to hold the entire message. In some cases this may require careful planning; there is no general facility to probe a message size before you receive it. If your receive buffer is not large enough to accommodate a whole message, the message will be truncated.

The UDP protocol is a special case of a message channel. An unconnected UDP channel sends and receives not only a message payload but also address payloads. Because of this, a plain message channel does not suffice as it only manages the payload itself. For this case, there is a special MultipointMessageChannel type family, whose send and receive methods include arguments for source and destination address specification. There is also the MulticastMessageChannel interface to allow for multi-point message channels which are multicast-capable.

JBoss.org Content Archive (Read Only), exported from JBoss Community Documentation Editor at 2020-03-13 13:59:27 UTC, last content change 2012-07-12 17:34:52 UTC.